function getQueryString(name) { 
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
    var r = window.location.search.substr(1).match(reg); 
    if (r != null) return unescape(r[2]); 
    return null; 
} 
var ifcontact = getQueryString('contact');
console.log(ifcontact)
if(ifcontact == "contact"){
    window.location.href="#foot"
}
var mySwiper = new Swiper('#bannerbig', {
    autoplay: {
        delay: 1500,
        disableOnInteraction: false,
    },//可选选项，自动滑动
    effect: 'fade',
    loop: true,
    speed: 2000,
    pagination: {
        el: '.swiper-pagination',
        clickable: true,
    },
})
var mySwiper1 = new Swiper('#bannerm', {
    autoplay: {
        delay: 2500,
        disableOnInteraction: false,
    },//可选选项，自动滑动
    effect : 'fade',
    loop: true,
    speed: 800,
    pagination: {
        el: '.swiper-pagination',
        clickable: true,
    },
})
var bookname = $(".list").find(".names");
for (var i = 0; i < bookname.length; i++) {
    var name = bookname.eq(i).html()
    if (name.length > 7) {
        bookname.eq(i).html(name.substring(0, 7) + '...')
    }


};
var Swiper1 = new Swiper('.xdimg', {
    slidesPerView: 2,
    spaceBetween: -30,
    centeredSlides: true,
    loop: true,
    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
    },
    on: {
        init: function () {
            $(".xdword").find("div").eq(0).show()
        },
        slideChangeTransitionEnd: function () {
            $(".xdword").find("div").hide();
            if (this.activeIndex == 2 || this.activeIndex == 5) {
                $(".xdword").find("div").eq(0).show()
            } else if (this.activeIndex == 1 || this.activeIndex == 4) {
                $(".xdword").find("div").eq(1).show()
            } else {
                $(".xdword").find("div").eq(2).show()
            }
            console.log(this.activeIndex);//切换结束时，告诉我现在是第几个slide
        },
    },
});
var Swiper2 = new Swiper('.gdimg', {
    slidesPerView: 2,
    spaceBetween: -30,
    centeredSlides: true,
    loop: true,
    navigation: {
        nextEl: '.snext',
        prevEl: '.sprev',
    },
    on: {
        init: function () {
            $(".gdword").find("div").eq(0).show()
        },
        slideChangeTransitionStart: function () {
            $(".gdword").find("div").hide();
            if (this.activeIndex == 2 || this.activeIndex == 5) {
                $(".gdword").find("div").eq(0).show()
            } else if (this.activeIndex == 1 || this.activeIndex == 4) {
                $(".gdword").find("div").eq(1).show()
            } else {
                $(".gdword").find("div").eq(2).show()
            }
            console.log(this.activeIndex);//切换结束时，告诉我现在是第几个slide
        },
    },
});

var swiper = new Swiper('#product', {
    direction: 'vertical',
    mousewheel:true,
    pagination: {
      el: '.swiper-pagination',
      clickable: true,
    },
  });


//   编辑强推
$.ajax({
    url: baseurl + `/book/list`,
    type: 'get',
    dataType: 'json',
    async:false,
    success: function (e) {
        
        var book=e.data.list;
        var index = 1;
        var nindex = 1;
        for(let i = 0;i<5;i++){
            var books = `<li>
            <a href="bookdetail.html">
                <div class="original">
                    <p class="biao">
                    ${index++}
                    </p>
                    <p class="name" title="${book[i].name}">
                        [${book[i].typeDetail}] <span> ${book[i].name}</span>
                    </p>
                </div>
                <div class="now">
                    <p class="biao">
                        ${nindex++}
                    </p>
                    <p class="cover">
                        <img src="${book[i].cover}" alt="">
                    </p>
                    <div>
                        <p class="name" title="${book[i].name}">
                        ${book[i].name}
                        </p>
                        <p class="author">
                        ${book[i].nickName}
                        </p>
                        <p class="lei">
                        ${book[i].typeDetail}
                        </p>
                    </div>
                </div>
            </a>
        </li>`
        $("#editT").append(books);
        var editlist = $(".editlist").find("li");
        $(".original").eq(0).addClass("hide")
        $(".now").eq(0).addClass("show")
        editlist.mouseover(function () {
            $(".original").removeClass("hide")
            $(".now").removeClass("show")
            $(this).find(".original").addClass("hide")
            $(this).find(".now").addClass("show")
        });
        } 
    }
});